package com.feishi.core.socket.common;

import com.feishi.core.analytic.assembler.BaseAssembler;
import com.feishi.core.util.common.bean.ByteBufferProxy;

/**
 * @version 1.0
 * @auth caixq
 * @time 18-3-28 19:36
 **/
public interface SocketDecoder<T extends BaseAssembler> {
     byte[] decode(ByteBufferProxy bfp);
     default T decode(byte[] bytes){

          T assembler = null;
          try {
               assembler = getAssemblerClass().newInstance();
               assembler.decode(bytes);
          } catch (InstantiationException e) {
               e.printStackTrace();
          } catch (IllegalAccessException e) {
               e.printStackTrace();
          }
          return assembler;
     }

     Class<T> getAssemblerClass();
}
